var Adv_skd=require("./Adv_skd")

var e = require;
var t = module;
var o = exports;
var n;
Object.defineProperty(o, "__esModule", {value: !0}), (o.TreasureChestSmall = void 0);
var r = e("SDK"),
    s = e("AdUtils"),
    c = e("TreasureChestBox"),
    l = cc._decorator,
    d = l.ccclass,
    u =
        (l.property,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (
                    (t.vider_icon = null),
                    (t.reward = null),
                    (t.victorychest = null),
                    (t.isClick = !0),
                    (t.count = null),
                    (t.icon_1 = null),
                    (t.icon_2 = null),
                    (t.cb = null),
                    t
                );
            }
            return (
                __extends(t, e),
                (t.prototype.onLoad = function () {
                    (this.vider_icon = this.node.getChildByName("bg").getChildByName("video_icon")),
                        (this.victorychest = this.node.getChildByName("bg").getChildByName("victorychest")),
                        (this.reward = this.node.getChildByName("bg").getChildByName("reward")),
                        (this.count = this.reward.getChildByName("count").getComponent(cc.Label)),
                        (this.icon_1 = this.reward.getChildByName("icon_1")),
                        (this.icon_2 = this.reward.getChildByName("icon_2"));
                }),
                (t.prototype.init = function (e) {
                    void 0 === e && (e = null),
                        (this._data = e),
                        this._data &&
                            ((this.type = this._data.type),
                            this._data.type == c.TreasureBox.COIN
                                ? this.initCoin()
                                : this._data.type == c.TreasureBox.DIAMONDS
                                ? this.initDiamonds()
                                : this._data.type == c.TreasureBox.RADOM &&
                                  ((this.type = s.default.instance.getRandomInt(1, 2)),
                                  this.type == c.TreasureBox.COIN
                                      ? this.initCoin()
                                      : this.type == c.TreasureBox.DIAMONDS && this.initDiamonds()));
                }),
                (t.prototype.initCoin = function () {
                    var e = this;
                    (this.coinData = this._data.coin),
                        this.coinData &&
                            (s.default.instance.loadPrefabs(this.coinData.res, function (t) {
                                e.icon_1.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                            }),
                            (this.attribute = s.default.instance.getRandomInt(this.coinData.min, this.coinData.max)),
                            (this.count.string = this.attribute + ""));
                }),
                (t.prototype.initDiamonds = function () {
                    var e = this;
                    (this.diamondsData = this._data.diamonds),
                        this.diamondsData &&
                            (s.default.instance.loadPrefabs(this.diamondsData.res, function (t) {
                                e.icon_1.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                            }),
                            (this.attribute = s.default.instance.getRandomInt(
                                this.diamondsData.min,
                                this.diamondsData.max
                            )),
                            (this.count.string = this.attribute + ""));
                }),
                (t.prototype.start = function () {}),
                (t.prototype.setVider_icon = function () {
                    this.isClick && (this.vider_icon.active = !0);
                }),
                (t.prototype.getReward = function () {
                    this.cb && !this.isClick && this.cb(this.type, this.attribute);
                }),
                (t.prototype.getVider_icon = function () {
                    return this.vider_icon.active;
                }),
                (t.prototype.video_Ok = function (e) {
                    var t = this;
                    this.vider_icon.active
                        ? 
                        //   r.default.Instance.showRewardVideo(
                        //       function () {
                        //           t.victorychest.getComponent(sp.Skeleton).setAnimation(0, "open_first", !1),
                        //               console.log("视频播放成功"),
                        //               (t.vider_icon.active = !1),
                        //               t.video_Ok(e);
                        //       },
                        //       function () {
                        //           r.default.Instance.showToast("看完视频才能领取奖励哦~~");
                        //       },
                        //       function () {
                        //           r.default.Instance.showToast("暂无广告");
                        //       }
                        //   ))
                        Adv_skd.default.instance.showVideo(()=>{
                            t.victorychest.getComponent(sp.Skeleton).setAnimation(0, "open_first", !1),
                            console.log("视频播放成功"),
                            (t.vider_icon.active = !1),
                            t.video_Ok(e);
                        },()=>{})
                             
                        : ((this.isClick = !1),
                          this.scheduleOnce(function () {
                              (t.reward.active = !0),
                                  t.type == c.TreasureBox.COIN
                                      ? (t.icon_1.active = !0)
                                      : t.type == c.TreasureBox.DIAMONDS && (t.icon_1.active = !0),
                                  e(t.type, t.attribute),
                                  (t.cb = e),
                                  console.log("发放奖励！！！");
                          }, 0.5));
                }),
                (t.prototype.close = function () {
                    (this.isClick = !0),
                        (this.reward.active = !1),
                        (this.vider_icon.active = !1),
                        (this.victorychest.active = !0);
                }),
                __decorate([d("TreasureChestSmall")], t)
            );
        })(cc.Component));
o.TreasureChestSmall = u;
